.class abstract Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;
.super Ljava/lang/Object;
.source "AbstractCalendarEventsHandler.java"


# static fields
.field private static final DAYS_MAP:Landroid/util/SparseArray;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/util/SparseArray",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt;

.field private static final TAG:Ljava/lang/String;


# instance fields
.field protected mCallback:Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;

.field protected mContext:Landroid/content/Context;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 36
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 41
    const-class v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->TAG:Ljava/lang/String;

    .line 46
    new-instance v0, Landroid/util/SparseArray;

    const/4 v1, 0x7

    invoke-direct {v0, v1}, Landroid/util/SparseArray;-><init>(I)V

    sput-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    .line 49
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x0

    const-string v2, "SU"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 50
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x1

    const-string v2, "MO"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 51
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x2

    const-string v2, "TU"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 52
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x3

    const-string v2, "WE"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 53
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x4

    const-string v2, "TH"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 54
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x5

    const-string v2, "FR"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 55
    sget-object v0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    const/4 v1, 0x6

    const-string v2, "SA"

    invoke-virtual {v0, v1, v2}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    .line 57
    return-void
.end method

.method constructor <init>(Landroid/content/Context;Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;)V
    .locals 0
    .parameter "context"
    .parameter "callback"

    .prologue
    .line 136
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 137
    iput-object p1, p0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->mContext:Landroid/content/Context;

    .line 138
    iput-object p2, p0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->mCallback:Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;

    .line 139
    return-void
.end method

.method private static appendArray(Ljava/lang/String;Ljava/lang/StringBuilder;[Ljava/lang/Object;)V
    .locals 2
    .parameter "arrayCondition"
    .parameter "appendTo"
    .parameter "arrayOfValues"

    .prologue
    .line 115
    if-eqz p2, :cond_0

    array-length v0, p2

    if-lez v0, :cond_0

    .line 116
    invoke-virtual {p1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, ","

    invoke-static {p2, v1}, Lcom/burstly/lib/util/Utils;->arrayToString([Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, ";"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 118
    :cond_0
    return-void
.end method

.method protected static parseEventRepeatRule(Lcom/burstly/lib/util/calendar/EventRepeatRule;)Ljava/lang/String;
    .locals 7
    .parameter "repeatRule"

    .prologue
    .line 64
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    .line 65
    .local v2, rule:Ljava/lang/StringBuilder;
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->frequency:Ljava/lang/String;

    if-eqz v3, :cond_0

    .line 66
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->frequency:Ljava/lang/String;

    const-string v4, "daily"

    invoke-virtual {v3, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_3

    .line 67
    const-string v3, "FREQ=DAILY;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 68
    invoke-static {p0, v2}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->setUntilDate(Lcom/burstly/lib/util/calendar/EventRepeatRule;Ljava/lang/StringBuilder;)V

    .line 94
    :cond_0
    :goto_0
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->interval:Ljava/lang/Integer;

    if-eqz v3, :cond_1

    .line 95
    const-string v3, "INTERVAL="

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->interval:Ljava/lang/Integer;

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, ";"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 97
    :cond_1
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->exceptionDates:[Ljava/lang/String;

    if-eqz v3, :cond_2

    .line 98
    sget-object v3, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v4, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->TAG:Ljava/lang/String;

    const-string v5, "exceptionDates not supported"

    const/4 v6, 0x0

    new-array v6, v6, [Ljava/lang/Object;

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 100
    :cond_2
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    return-object v3

    .line 69
    :cond_3
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->frequency:Ljava/lang/String;

    const-string v4, "weekly"

    invoke-virtual {v3, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_6

    .line 70
    const-string v3, "FREQ=WEEKLY;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 71
    invoke-static {p0, v2}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->setUntilDate(Lcom/burstly/lib/util/calendar/EventRepeatRule;Ljava/lang/StringBuilder;)V

    .line 72
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInWeek:[Ljava/lang/Integer;

    if-eqz v3, :cond_0

    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInWeek:[Ljava/lang/Integer;

    array-length v3, v3

    if-lez v3, :cond_0

    .line 73
    const-string v3, "BYDAY="

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 74
    const/4 v0, 0x0

    .local v0, i:I
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInWeek:[Ljava/lang/Integer;

    array-length v1, v3

    .local v1, len:I
    :goto_1
    if-ge v0, v1, :cond_5

    .line 75
    sget-object v3, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->DAYS_MAP:Landroid/util/SparseArray;

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInWeek:[Ljava/lang/Integer;

    aget-object v4, v4, v0

    invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I

    move-result v4

    invoke-virtual {v3, v4}, Landroid/util/SparseArray;->get(I)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 76
    add-int/lit8 v3, v0, 0x1

    if-eq v3, v1, :cond_4

    .line 77
    const-string v3, ","

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 74
    :cond_4
    add-int/lit8 v0, v0, 0x1

    goto :goto_1

    .line 80
    :cond_5
    const-string v3, ";"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    goto :goto_0

    .line 82
    .end local v0           #i:I
    .end local v1           #len:I
    :cond_6
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->frequency:Ljava/lang/String;

    const-string v4, "monthly"

    invoke-virtual {v3, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_7

    .line 83
    const-string v3, "FREQ=MONTHLY;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 84
    invoke-static {p0, v2}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->setUntilDate(Lcom/burstly/lib/util/calendar/EventRepeatRule;Ljava/lang/StringBuilder;)V

    .line 85
    const-string v3, "BYMONTHDAY="

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInMonth:[Ljava/lang/Integer;

    invoke-static {v3, v2, v4}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->appendArray(Ljava/lang/String;Ljava/lang/StringBuilder;[Ljava/lang/Object;)V

    .line 86
    const-string v3, "BYWEEKNO="

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->weeksInMonth:[Ljava/lang/Integer;

    invoke-static {v3, v2, v4}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->appendArray(Ljava/lang/String;Ljava/lang/StringBuilder;[Ljava/lang/Object;)V

    goto/16 :goto_0

    .line 87
    :cond_7
    iget-object v3, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->frequency:Ljava/lang/String;

    const-string v4, "yearly"

    invoke-virtual {v3, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 88
    const-string v3, "FREQ=YEARLY;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 89
    invoke-static {p0, v2}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->setUntilDate(Lcom/burstly/lib/util/calendar/EventRepeatRule;Ljava/lang/StringBuilder;)V

    .line 90
    const-string v3, "BYYEARDAY="

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->daysInYear:[Ljava/lang/Integer;

    invoke-static {v3, v2, v4}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->appendArray(Ljava/lang/String;Ljava/lang/StringBuilder;[Ljava/lang/Object;)V

    .line 91
    const-string v3, "BYMONTH="

    iget-object v4, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->monthsInYear:[Ljava/lang/Integer;

    invoke-static {v3, v2, v4}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->appendArray(Ljava/lang/String;Ljava/lang/StringBuilder;[Ljava/lang/Object;)V

    goto/16 :goto_0
.end method

.method private static setUntilDate(Lcom/burstly/lib/util/calendar/EventRepeatRule;Ljava/lang/StringBuilder;)V
    .locals 2
    .parameter "repeatRule"
    .parameter "rule"

    .prologue
    .line 108
    iget-object v0, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->expires:Ljava/lang/String;

    if-eqz v0, :cond_0

    .line 109
    const-string v0, "UNTIL="

    invoke-virtual {p1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget-object v1, p0, Lcom/burstly/lib/util/calendar/EventRepeatRule;->expires:Ljava/lang/String;

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, ";"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 111
    :cond_0
    return-void
.end method


# virtual methods
.method protected abstract populateIntent(Landroid/content/Intent;Lcom/burstly/lib/util/calendar/CalendarEvent;)V
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation
.end method

.method final scheduleEvent(Lcom/burstly/lib/util/calendar/CalendarEvent;)V
    .locals 4
    .parameter "event"

    .prologue
    .line 145
    new-instance v1, Landroid/content/Intent;

    invoke-direct {v1}, Landroid/content/Intent;-><init>()V

    .line 147
    .local v1, intent:Landroid/content/Intent;
    :try_start_0
    invoke-virtual {p0, v1, p1}, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->populateIntent(Landroid/content/Intent;Lcom/burstly/lib/util/calendar/CalendarEvent;)V

    .line 148
    iget-object v2, p0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->mContext:Landroid/content/Context;

    invoke-virtual {v2, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    .line 149
    iget-object v2, p0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->mCallback:Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;

    invoke-interface {v2}, Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;->addedSuccessfully()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 154
    :goto_0
    return-void

    .line 151
    :catch_0
    move-exception v0

    .line 152
    .local v0, exception:Ljava/lang/Exception;
    iget-object v2, p0, Lcom/burstly/lib/util/calendar/AbstractCalendarEventsHandler;->mCallback:Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;

    const-string v3, "Can not save an event"

    invoke-interface {v2, v3}, Lcom/burstly/lib/util/calendar/CalendarEventsHandler$IEventsHandlerCallback;->errorOccured(Ljava/lang/String;)V

    goto :goto_0
.end method
